<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="language" content="en" />
        <title><?php echo CHtml::encode($this->pageTitle); ?></title>
        <link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/icon/favicon.ico" type="image/x-icon" />
        <!-- blueprint CSS framework -->
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/css.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/cssmenu.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/buttons.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/pager.css" />
        <link href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/menuV2.css" rel="stylesheet" type="text/css" />

        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

        <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/flexslider.css" type="text/css" media="screen" />

        <!-- Modernizr -->
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/flexslider/modernizr.js"></script>

        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/home/menuV2.js" type="text/javascript"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/home/jquery.countdown.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/skins/tango/skin.css" />

        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/productslider/jquery.jcarousel.min.js"></script>


        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.msgBox/Scripts/jquery.msgBox.js"></script>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.msgBox/Styles/msgBoxLight.css" />
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/ui/jquery-ui.js"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jPages/jPages.js"></script>
          <script type="text/javascript">
         $(document).ready(function() {
                $('a.login-window').click(function() {

                    // Getting the variable's value from a link 
                    var loginBox = $(this).attr('href');

                    //Fade in the Popup and add close button
                    $(loginBox).fadeIn(300);

                    //Set the center alignment padding + border
                    var popMargTop = ($(loginBox).height() + 24) / 2;
                    var popMargLeft = ($(loginBox).width() + 24) / 2;

                    $(loginBox).css({
                        'margin-top': -popMargTop,
                        'margin-left': -popMargLeft
                    });

                    // Add the mask to body
                    $('body').append('<div id="mask"></div>');
                    $('#mask').fadeIn(300);

                    return false;
                });

                // When clicking on the button close or the mask layer the popup closed
                $('a.close, #mask').live('click', function() {
                    $('#mask , .login-popup').fadeOut(300, function() {
                        $('#mask').remove();
                    });
                    return false;
                });
            });
        </script>
    </head>
    <body>
        <div id="div-toTop" style="display: block;">
            <img src="<?php echo Yii::app()->request->baseUrl; ?>/icon/backtop.png">
        </div>



        <?php
        $baner = Yii::app()->cache->get('baner');
        if ($baner === FALSE) {
            $baner = Panel::model()->findAll(
                    array(
                        'condition' => ' `flag`=1 and `type` in(4,5) and `dateCreate`<= CURDATE() and `dateEpend`>=CURDATE() order by vitri ASC',
                        'limit' => 100,
                    )
            );
            Yii::app()->cache->set('baner', $baner, 7200);
        }
        if (!empty($baner)) {
            $lan = 0;
            $right = '';
            $flag = 0;
            $dem = 0;
            $dem1 = 0;
            $left = '';
            foreach ($baner as $b) {

                $h = 0;
                if ($b->type == 5) {
                    $lan = $lan + 1;

                    if ($b->kieu == 0) {
                        $h = 240;
                    } elseif ($b->kieu == 1) {
                        $h = 480;
                        $flag = 1;
                    }
                    if ($lan < 2) {
                        $left = $left . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                    } elseif ($lan < 7) {
                        $left = $left . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                    } elseif ($lan > 6) {
                        $left = $left . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                        $dem = 0;
                    }
                } else {
                    $flag = 2;
                    if ($b->kieu == 0) {
                        $dem = $dem + 1;
                        $h = 240;
                        if ($dem < 2) {
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        } elseif ($dem < 7) {
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        } elseif ($dem > 6) {
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                            $dem = 0;
                        }
                    } elseif ($b->kieu == 2) {

                        $h = 240 + 240;
                        if ($dem == 1) {
                            $dem = 0;
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                        } else {
                            $dem = 3;
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        }
                    } elseif ($b->kieu == 3) {
                        $h = 792;
                        $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                    }
                }
            }
        }
        ?>

        <?php
        /*
          $a = Yii::app()->controller->action->id;
          echo '<br/> action '.$a;
          $b = Yii::app()->controller->id;
          echo '<br/> ctroler '.$b;
          echo '<br/>';
         */


        $this->renderPartial('//layouts/header');
        ?>

        <div id="nd" style="padding-top: 64px;" >

            <div style="width: 1349px; margin: auto;">
                <div style="width: 180px; float: left;margin-left: 10px;padding-top: 10px">
                    <?php
                    if (!empty($left)) {
                        ?>
                        <ul id="mycarousel5" class="jcarousel-skin-chacha">
                            <?php echo $left; ?>

                        </ul>


                        <?php
                    }
                    ?>
                </div>
                <div style="width: 963px; float: left;">

                    <div style="width: 960px; margin: auto; ">
                        <div class="noidungfix" id="content0">
                            <div>
                                <div class="colleft">
                                    <?php
                                    $this->renderPartial('//layouts/nabar_home');
                                    ?>
                                    <div style="clear: both"></div>
                                </div>

                                <div class="colright" style="margin: 0px;height: 379px;">

                                    <?php
                                    $this->renderPartial('//site/slider');
                                    ?>

                                    <div style="clear: both"></div>
                                </div>

                            </div>

                            <div  style="clear: both"></div>
                            <div id="to"></div>
                        </div>
                     
                           <div class="clear"></div>
                        <div>
                            <?php echo $content; ?>
                            <div class="clear"></div>
                        </div>
                    </div>
                </div>
                <div style="width: 180px;float: right;margin-right: 10px;padding-top: 10px">
                    <?php
                    if (!empty($flag)) {
                        if ($flag > 1) {
                            ?>
                            <ul id="mycarousel1" class="jcarousel-skin-chacha">
                                <?php echo $right; ?>

                            </ul>
                            <?php
                        }
                    }
                    ?>
                </div>
            </div>








            <div class="clear"></div>
            <?php
            $this->renderPartial('//layouts/footer_1');
            ?>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
        <script type="text/javascript">
            $(function() {
                $(window).scroll(function() {
                    if ($(this).scrollTop() != 0) {
                        $('#div-toTop').fadeIn();
                    } else {
                        $('#div-toTop').fadeOut();
                    }
                });
                $('#div-toTop').click(function() {
                    $('body,html').animate({scrollTop: 0}, 800);
                });
            });
        </script>
    </body>
</html>
